home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / plnk081.zip / pilot-link.0.8.1 / Tcl / tkAppInit.c < prev   
C/C++ Source or Header  |  1997-06-29  |  3KB  |  126 lines

  1. /* 
  2.  * tkAppInit.c --
  3.  *
  4.  *    Provides a default version of the Tcl_AppInit procedure for
  5.  *    use in wish and similar Tk-based applications.
  6.  *
  7.  * Copyright (c) 1993 The Regents of the University of California.
  8.  * Copyright (c) 1994 Sun Microsystems, Inc.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * SCCS: @(#) tkAppInit.c 1.21 96/03/26 16:47:07
  14.  */
  15.  
  16. #include "tk.h"
  17.  
  18. /*
  19.  * The following variable is a special hack that is needed in order for
  20.  * Sun shared libraries to be used for Tcl.
  21.  */
  22.  
  23. extern int matherr();
  24. int *tclDummyMathPtr = (int *) matherr;
  25.  
  26. EXTERN int        Pdapilot_Init _ANSI_ARGS_((Tcl_Interp *interp));
  27.  
  28. #ifdef TK_TEST
  29. EXTERN int        Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
  30. #endif /* TK_TEST */
  31.  
  32. /*
  33.  *----------------------------------------------------------------------
  34.  *
  35.  * main --
  36.  *
  37.  *    This is the main program for the application.
  38.  *
  39.  * Results:
  40.  *    None: Tk_Main never returns here, so this procedure never
  41.  *    returns either.
  42.  *
  43.  * Side effects:
  44.  *    Whatever the application does.
  45.  *
  46.  *----------------------------------------------------------------------
  47.  */
  48.  
  49. int
  50. main(argc, argv)
  51.     int argc;            /* Number of command-line arguments. */
  52.     char **argv;        /* Values of command-line arguments. */
  53. {
  54.     Tk_Main(argc, argv, Tcl_AppInit);
  55.     return 0;            /* Needed only to prevent compiler warning. */
  56. }
  57.  
  58. /*
  59.  *----------------------------------------------------------------------
  60.  *
  61.  * Tcl_AppInit --
  62.  *
  63.  *    This procedure performs application-specific initialization.
  64.  *    Most applications, especially those that incorporate additional
  65.  *    packages, will have their own version of this procedure.
  66.  *
  67.  * Results:
  68.  *    Returns a standard Tcl completion code, and leaves an error
  69.  *    message in interp->result if an error occurs.
  70.  *
  71.  * Side effects:
  72.  *    Depends on the startup script.
  73.  *
  74.  *----------------------------------------------------------------------
  75.  */
  76.  
  77. int
  78. Tcl_AppInit(interp)
  79.     Tcl_Interp *interp;        /* Interpreter for application. */
  80. {
  81.     if (Tcl_Init(interp) == TCL_ERROR) {
  82.     return TCL_ERROR;
  83.     }
  84.     if (Tk_Init(interp) == TCL_ERROR) {
  85.     return TCL_ERROR;
  86.     }
  87.     if (Pdapilot_Init(interp) == TCL_ERROR) {
  88.         return TCL_ERROR;
  89.     }
  90.     Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);
  91. #ifdef TK_TEST
  92.     if (Tktest_Init(interp) == TCL_ERROR) {
  93.     return TCL_ERROR;
  94.     }
  95.     Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
  96.             (Tcl_PackageInitProc *) NULL);
  97. #endif /* TK_TEST */
  98.  
  99.  
  100.     /*
  101.      * Call the init procedures for included packages.  Each call should
  102.      * look like this:
  103.      *
  104.      * if (Mod_Init(interp) == TCL_ERROR) {
  105.      *     return TCL_ERROR;
  106.      * }
  107.      *
  108.      * where "Mod" is the name of the module.
  109.      */
  110.  
  111.     /*
  112.      * Call Tcl_CreateCommand for application-specific commands, if
  113.      * they weren't already created by the init procedures called above.
  114.      */
  115.  
  116.     /*
  117.      * Specify a user-specific startup file to invoke if the application
  118.      * is run interactively.  Typically the startup file is "~/.apprc"
  119.      * where "app" is the name of the application.  If this line is deleted
  120.      * then no user-specific startup file will be run under any conditions.
  121.      */
  122.  
  123.     Tcl_SetVar(interp, "tcl_rcFileName", "~/.piwishrc", TCL_GLOBAL_ONLY);
  124.     return TCL_OK;
  125. }
  126.